var t = getApp();

Page({
    data: {
        active: 0,
        showBox: !1,
        listHeight: 0,
        recordsList: [],
        isLoadMore: !0,
        dataInfo: {},
        page: 1,
        total_page: 0,
        record: {}
    },
    onLoad: function(t) {},
    onShow: function() {
        this.getData();
    },
    toSign: function(t) {
        var a = t.currentTarget.dataset.record;
        this.setData({
            record: a
        }), wx.navigateTo({
            url: "/packageH/signPage/signPage?id=".concat(a.id)
        });
    },
    stopUse: function(t) {
        var a = t.currentTarget.dataset.record;
        this.setData({
            record: a
        }), wx.showModal({
            content: "确定取消吗",
            success: function() {
                this.cancelQuery();
            }
        });
    },
    cancelQuery: function() {
        var a = this, e = t.getNetAddresss("plugin.yun-sign.frontend.h5.contract.cancel");
        wx.showLoading({
            title: "正在取消",
            mask: !0
        }), t._getNetWork({
            url: e,
            data: {
                id: a.data.record
            },
            success: function(e) {
                1 === e.data.result ? (a.setData({
                    recordsList: []
                }), a.getData(), wx.hideLoading(), t.tips("取消成功")) : t.tips("取消失败");
            },
            fail: function(t) {
                wx.hideLoading(), console.log(t, "------ 失败 -------");
            }
        });
    },
    downpdf: function(a) {
        console.log("下载PDF");
        var e = a.currentTarget.dataset.record.download_url;
        wx.downloadFile({
            url: e,
            success: function(a) {
                console.log(a, "成功");
                var e = a.tempFilePath;
                wx.openDocument({
                    filePath: e,
                    success: function() {
                        t.tips("文件打开成功");
                    },
                    fail: function() {
                        t.tips("打开文件失败");
                    }
                });
            },
            fail: function(t) {
                console.log(t, "是失败"), wx.showModal({
                    content: "下载失败，请重新下载"
                });
            }
        });
    },
    tabChange: function(t) {
        this.setData({
            active: 1 * t.detail.name
        }), this.getData();
    },
    getData: function() {
        this.setData({
            page: 1
        });
        var a = this, e = t.getNetAddresss("plugin.yun-sign.frontend.h5.contract.get-list");
        wx.showLoading({
            title: "正在取消",
            mask: !0
        }), t._getNetWork({
            url: e,
            data: {
                page: 1,
                status: a.data.active
            },
            success: function(e) {
                console.log(e), wx.hideLoading();
                var o = e.data;
                1 === o.result ? (a.setData({
                    isLoadMore: !0,
                    recordsList: o.data.data,
                    dataInfo: o.data,
                    total_page: o.data.last_page
                }), a.data.total_page || a.setData({
                    total_page: 0
                })) : t.tips(o.msg);
            },
            fail: function(t) {
                wx.hideLoading(), console.log(t, "------失败-------");
            }
        });
    },
    getMoreData: function() {
        var a = this;
        if (this.data.isLoadMore) if (this.data.page >= this.data.total_page) this.setData({
            isLoadMore: !1
        }); else {
            this.setData({
                page: this.data.page + 1
            });
            var e = t.getNetAddresss("plugin.yun-sign.frontend.h5.contract.get-list");
            wx.showLoading({
                title: "正在取消",
                mask: !0
            }), t._getNetWork({
                url: e,
                data: {
                    page: a.data.page,
                    status: a.data.active
                },
                success: function(t) {
                    wx.hideLoading();
                    var e = t.data;
                    if (1 === e.result) {
                        var o = e.data.data, s = a.data.recordsList.concat(o);
                        a.setData({
                            isLoadMore: !0,
                            recordsList: s
                        });
                    } else a.setData({
                        page: a.data.page - 1,
                        isLoadMore: !1
                    });
                },
                fail: function(t) {
                    console.log(t, "-------失败 -----------"), a.setData({
                        isLoadMore: !0
                    }), wx.hideLoading();
                }
            });
        } else t.tips("没有更多了");
    },
    getlistHeight: function() {
        var t = this, a = wx.createSelectorQuery();
        a.select("#tabs").boundingClientRect();
        var e = 600;
        try {
            var o = wx.getSystemInfoSync();
            e = o.windowHeight;
        } catch (t) {
            console.log(t);
        }
        a.exec(function(a) {
            t.setData({
                listHeight: e - a[0].height + "px"
            });
        });
    },
    handlerImg: function() {
        this.setData({
            showBox: !this.data.showBox
        });
    },
    onHide: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多数据");
    }
});